<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
<head>
<meta  charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
		<title>我的订单</title>
	<link href="${pageContext.request.contextPath}/bettery/css/itao.css"	rel="stylesheet" /> 
		<script type="text/javascript" src="${pageContext.request.contextPath}/dewei/js/jquery.js"></script>
		<script src="${pageContext.request.contextPath}/dewei/js/alert.js"></script>
<style type="text/css">
 
ul.products {
	margin: 0px;
	list-style: none;
	padding: 0px;
}
ul.products li {

	
	font-size: 12px;
	padding: 3px 5px;height:auto;
}

ul.products li:hover {

}

ul.products li img,ul.products li .info,ul.products li .oper {
	display: inline-block;vertical-align: middle;
}
ul.products li .btn{
	float: left;height: 24px;margin-top: 2px;margin-right: 1px;padding: 1px 10px;width: 48.5%;
}
.btn-pane{
	
}
.btn-pane .btnBlack{
	width:48%;
}
.btnBlack{
	text-align:center;width:48%;margin-right:5px
}
</style>
</head>
<body>
	<div  class='search_bar'>
		 订单信息 
	</div>
	<div class='col-lg-12'>
		<ul class="products">
			<s:iterator value="dingdans">
				<li id="li${id}" class='panel'>
				   <div class='panel-body' style='padding:5px'>
					<img xSrc="${imageUrl}" src="${pageContext.request.contextPath}/dewei/img/wait.gif" width="140px;" height="96px;">
					<div class='info'>
						<div>
							订单号：${dingDanUid}
						</div>
						<div>
							电池品牌：${pinPai}
						</div>
						<div>
							电池型号：${xingHao}
						</div>
						<div>
							换购价格：${price}元
						</div>
						<div>
							更换方式：${changeType}
						</div>
						
						<div>
							处理状态：<span id="span${id}"><s:if test='"0"==state'>已下单</s:if>
					    <s:elseif test='"2"==state'>已指派</s:elseif>
						<s:elseif	test='"4"==state'>已超期</s:elseif>
						<s:elseif test='"5"==state'>已核实</s:elseif> 
						<s:else>处理中</s:else></span>
						</div>
					    <s:if test='"附近门店更换"==changeType'>
					     </div>
					    
				        <div class='btn-pane'>
					      <a class='btnBlack' onclick='process1(${id},this)' state='${state}' state2='${state}' span='完成'>完成</a>
						  <a class='btnBlack' onclick='process2(${id})' >作废</a>
					    </div>
					 
						</s:if>
						<s:elseif test='"人工上门更换"==changeType'>
						</div>
						<div style="height: 75px;">
							<div>
								联系电话：${lxTel}
							</div>
							<div>
								客户地址：${address}
							</div>
							<div>
								客户姓名：${kehuName}
							</div>
							 
							<div  class='btn-pane'>
						      <a class='btnBlack' onclick='process1(${id},this)' state='${state}' state2='${state}' span='完成'>完成</a>
							  <a class='btnBlack' onclick='process2(${id})' >作废</a>
						    </div>
					    </div>
						</s:elseif>
						<s:elseif test='"附近无网点"==changeType'>
						</div>
						<div style="height: 75px;">
							<div>
								联系电话：${lxTel}
							</div>
							<div>
								客户地址：${address}
							</div>
							<div>
								客户姓名：${kehuName}
							</div>
							<div class='btn-pane'>
						      <a class='btnBlack' onclick='process1(${id},this)' state='${state}' state2='${state}' span='完成'>完成</a>
							  <a class='btnBlack' onclick='process2(${id})' >作废</a>
						    </div>
					    </div>
						</s:elseif>
					
					</div>
					
				</li>
			</s:iterator>
		</ul>
		</div>
		<script type="text/javascript">
		function process1(id,obj){
		  var state=$(obj).attr("state");
		  var state2=$(obj).attr("state2");
		  var t="撤销";
		  var s=$("#span"+id).html();
		  var s2=$(obj).attr("span");
		  $(obj).attr("span",s);
		  

		  if(state==state2){
			  $(obj).attr("state",'1');
			  state='1';
		  }else{
			   $(obj).attr("state",state2);
			   state=state2;
			   t="完成";
		  }
		  if(window.confirm("确定")){
			  $.ajax( {url : "processDingdan.do",
				     type : 'post',
				     data:{id:id,state:state},
				     dataType : "json",
				     success : function(html) {
				        $(obj).html(t);
				        $("#span"+id).html(s2);
				      }
			});
		  }
		}
		
		function process2(id){
			 if(window.confirm("确定作废，不可恢复")){
			  $.ajax( {url : "processDingdan.do",
				     type : 'post',
				     data:{id:id,state:'3'},
				     dataType : "json",
				     success : function(data) {
				    	 if(data.success){
				    		  $("#li"+id).remove();
				    	 }else{
				    		 alert("出错"+data.message);
				    	 }
				      }
			});
		  }
		}
		
    var scrollLoad = (function (options) {
        var defaults = (arguments.length == 0) ? { src: 'xSrc', time: 300} : { src: options.src || 'xSrc', time: options.time ||300};
        var camelize = function (s) {
            return s.replace(/-(\w)/g, function (strMatch, p1) {
                return p1.toUpperCase();
            });
        };
        this.getStyle = function (element, property) {
            if (arguments.length != 2) return false;
            var value = element.style[camelize(property)];
            if (!value) {
                if (document.defaultView && document.defaultView.getComputedStyle) {
                    var css = document.defaultView.getComputedStyle(element, null);
                    value = css ? css.getPropertyValue(property) : null;
                } else if (element.currentStyle) {
                    value = element.currentStyle[camelize(property)];
                }
            }
            return value == 'auto' ? '' : value;
        };
        var _init = function () {
            var offsetPage = window.pageYOffset ? window.pageYOffset : window.document.documentElement.scrollTop,
                offsetWindow = offsetPage + Number(window.innerHeight ? window.innerHeight : document.documentElement.clientHeight),
                docImg = document.images,
                _len = docImg.length;
            if (!_len) return false;
            for (var i = 0; i < _len; i++) {
                var attrSrc = docImg[i].getAttribute(defaults.src),
                    o = docImg[i], tag = o.nodeName.toLowerCase();
                if (o) {
                    postPage = o.getBoundingClientRect().top + window.document.documentElement.scrollTop + window.document.body.scrollTop; postWindow = postPage + Number(this.getStyle(o, 'height').replace('px', ''));
                    if ((postPage > offsetPage && postPage < offsetWindow) || (postWindow > offsetPage && postWindow < offsetWindow)) {
                        if (tag === "img" && attrSrc !== null) {
                            o.setAttribute("src", attrSrc);
                        }
                        o = null;
                    }
                }
            };
            window.onscroll = function () {
                setTimeout(function () {
                    _init();
                }, defaults.time);
            }
        };
        return _init();
    });
    scrollLoad();
</script> 
	</body>
</html>
